*******************************************************
*******************************************************
****** THIS PROGRAM PRODUCES RESULTS FOR TABLE 7 ******
*******************************************************
*******************************************************

clear 
cd "\\file\UsersW$\wrr15\Home\My Documents\My Files\TAXES AND ECONOMIC GROWTH IN OECD COUNTRIES - A META-ANALYSIS\SUBMISSION TO PFR\DATA AND PROGRAMS"
log using "Part2 Results(20200102).smcl", replace
set more off
set type double 
graph drop _all
import excel "TAX.xlsx", sheet("Stata") firstrow case (lower)
gen endog = (tsls == 1 | gmm == 1)

quietly summ coefficient, detail
scalar low = r(p5)
scalar high = r(p95)
keep if coefficient > low & coefficient < high

// For later Random Effects estimation
metareg coefficient peerreviewed pubyear cs length midyear gdp marginal differenced etr  ///
investment tradeopenness human popgrowth employgrowth unemployment inflation income laggeddv ///
countryfe sehac sehet lrcase2 lrcase3 gls endog eu15 g7 eumem ///
labourtax capitaltax othertaxes mixedtaxes overalltax predneg predpos se, wsse(se)
scalar tau2 = e(tau2)

*--------------------------------------------------------------------------------*
*   TABLE 7: Estimates of Tax Effects with Control Variables                     *
*--------------------------------------------------------------------------------*
// FIXED EFFECTS

// Generating transformed variables for FE
gen feprecision = 1/se
gen fetstat = coefficient/se
gen prednegg = predneg/se
gen predposs = predpos/se
gen peerreviewedd = peerreviewed/se
gen pubyearr = pubyear/se
gen css = cs/se
gen lengthh = length/se
gen midyearr = midyear/se
gen gdpp = gdp/se
gen marginall = marginal/se
gen differencedd = differenced/se
gen etrr = etr/se
gen investmentt = investment/se
gen tradeopennesss = tradeopenness/se
gen humann = human/se
gen popgrowthh = popgrowth/se
gen employgrowthh = employgrowth/se
gen unemploymentt = unemploymentrate/se
gen inflationn = inflation/se
gen incomee = income/se
gen laggeddvv = laggeddv/se
gen countryfee = countryfe/se
gen sehacc = sehac/se
gen sehett = sehet/se
gen lrcase22 = lrcase2/se
gen lrcase33 = lrcase3/se
gen glss = gls/se
gen endogg = endog/se
gen eu155 = eu15/se
gen g77 = g7/se
gen eumemm = eumem/se

// TABLE 7/PANEL A
// INCLUDING ALL VARIABLES
//This regression gives equal weight to each estimate
// TABLE 7 - Panel A/Column 1
regress fetstat feprecision endogg prednegg predposs peerreviewedd pubyearr css ///
lengthh midyearr gdpp marginall differencedd etrr investmentt tradeopennesss ///
humann popgrowthh employgrowthh unemploymentt inflationn incomee laggeddvv ///
countryfee sehacc sehett lrcase22 lrcase33 glss eu155 g77 eumemm, vce(cluster idstudy)
lincom -prednegg + predposs
//This regression gives equal weight to each study
// TABLE 7 - Panel A/Column 2
regress fetstat feprecision endogg prednegg predposs peerreviewedd pubyearr css ///
lengthh midyearr gdpp marginall differencedd etrr investmentt tradeopennesss ///
humann popgrowthh employgrowthh unemploymentt inflationn incomee laggeddvv ///
countryfee sehacc sehett lrcase22 lrcase33 glss eu155 g77 eumemm ///
[pweight = weight], vce(cluster idstudy)
lincom -prednegg + predposs

// TABLE 7/PANEL B
// USING BACKWARDS STEPWISE REGRESSION
//This regression gives equal weight to each estimate
// TABLE 7 - Panel B/Column 1
// Here we use backwards stepwise regression selecting on the best regression using the BIC criterion
// We lock in the variables: feprecision endogg prednegg predposs
vselect fetstat peerreviewedd pubyearr css lengthh midyearr gdpp marginall differencedd etrr  ///
investmentt tradeopennesss humann popgrowthh employgrowthh unemploymentt inflationn incomee laggeddvv ///
countryfee sehacc sehett lrcase22 lrcase33 glss eu155 g77 eumemm, backward bic ///
fix(feprecision endogg prednegg predposs)
// This estimates the "final best equation"
regress fetstat feprecision endogg prednegg predposs peerreviewedd gdpp ///
popgrowthh employgrowthh unemploymentt laggeddvv countryfee sehacc lrcase22 ///
glss eu155 g77, vce(cluster idstudy)
lincom -prednegg + predposs

//This regression gives equal weight to each study
// TABLE 7 - Panel B/Column 2
// Here we use backwards stepwise regression selecting on the best regression using the BIC criterion
// We lock in the variables: feprecision endogg prednegg predposs
vselect fetstat peerreviewedd pubyearr css lengthh midyearr gdpp marginall differencedd etrr  ///
investmentt tradeopennesss humann popgrowthh employgrowthh unemploymentt inflationn incomee laggeddvv ///
countryfee sehacc sehett lrcase22 lrcase33 glss eu155 g77 eumemm [pweight = weight], ///
backward bic fix(feprecision endogg prednegg predposs)
// This estimates the "final best equation"
regress fetstat feprecision endogg prednegg predposs peerreviewedd pubyearr ///
lengthh midyearr differencedd popgrowthh employgrowthh unemploymentt incomee ///
countryfee sehacc lrcase33 glss eu155 g77 [pweight = weight], vce(cluster idstudy)
lincom -prednegg + predposs

// RANDOM EFFECTS

// Generating transformed variables for RE

gen revar = se^2 + tau2
gen rese = sqrt(revar)
gen reprecision = 1/rese
gen retstat = coefficient/rese
gen repubbias = se/rese
replace prednegg = predneg/rese
replace predposs = predpos/rese
replace peerreviewedd = peerreviewed/rese
replace pubyearr = pubyear/rese
replace css = cs/rese
replace lengthh = length/rese
replace midyearr = midyear/rese
replace gdpp = gdp/rese
replace marginall = marginal/rese
replace differencedd = differenced/rese
replace etrr = etr/rese
replace investmentt = investment/rese
replace tradeopennesss = tradeopenness/rese
replace humann = human/rese
replace popgrowthh = popgrowth/rese
replace employgrowthh = employgrowth/rese
replace unemploymentt = unemploymentrate/rese
replace inflationn = inflation/rese
replace incomee = income/rese
replace laggeddvv = laggeddv/rese
replace countryfee = countryfe/rese
replace sehacc = sehac/rese
replace sehett = sehet/rese
replace lrcase22 = lrcase2/rese
replace lrcase33 = lrcase3/rese
replace glss = gls/rese
replace endogg = endog/rese
replace eu155 = eu15/rese
replace g77 = g7/rese
replace eumemm = eumem/rese


// TABLE 7/PANEL A
// INCLUDING ALL VARIABLES
//This regression gives equal weight to each estimate
// TABLE 7 - Panel A/Column 3
regress retstat reprecision repubbias endogg prednegg predposs peerreviewedd pubyearr css ///
lengthh midyearr gdpp marginall differencedd etrr investmentt tradeopennesss ///
humann popgrowthh employgrowthh unemploymentt inflationn incomee laggeddvv ///
countryfee sehacc sehett lrcase22 lrcase33 glss eu155 g77 eumemm, noc vce(cluster idstudy)
lincom -prednegg + predposs
//This regression gives equal weight to each study
// TABLE 7 - Panel A/Column 4
regress retstat reprecision repubbias endogg prednegg predposs peerreviewedd pubyearr css ///
lengthh midyearr gdpp marginall differencedd etrr investmentt tradeopennesss ///
humann popgrowthh employgrowthh unemploymentt inflationn incomee laggeddvv ///
countryfee sehacc sehett lrcase22 lrcase33 glss eu155 g77 eumemm ///
[pweight = weight],  noc vce(cluster idstudy)
lincom -prednegg + predposs


// TABLE 7/PANEL B
// USING BACKWARDS STEPWISE REGRESSION
//This regression gives equal weight to each estimate
// TABLE 7 - Panel B/Column 3
// Here we use backwards stepwise regression selecting on the best regression using the BIC criterion
// We lock in the variables: reprecision repubbias endogg prednegg predposs
vselect retstat peerreviewedd pubyearr css lengthh midyearr gdpp marginall differencedd etrr  ///
investmentt tradeopennesss humann popgrowthh employgrowthh unemploymentt inflationn incomee laggeddvv ///
countryfee sehacc sehett lrcase22 lrcase33 glss eu155 g77 eumemm, backward bic ///
fix(reprecision repubbias endogg prednegg predposs)
// This estimates the "final best equation"
regress retstat reprecision repubbias endogg prednegg predposs pubyearr midyearr gdpp ///
differencedd popgrowthh unemploymentt inflationn incomee sehacc lrcase22 lrcase33 eu155 g77, noc vce(cluster idstudy)
lincom -prednegg + predposs

//This regression gives equal weight to each study
// TABLE 7 - Panel B/Column 4
// Here we use backwards stepwise regression selecting on the best regression using the BIC criterion
// We lock in the variables: reprecision repubbias endogg prednegg predposs
vselect retstat peerreviewedd pubyearr css lengthh midyearr gdpp marginall differencedd etrr  ///
investmentt tradeopennesss humann popgrowthh employgrowthh unemploymentt inflationn incomee laggeddvv ///
countryfee sehacc sehett lrcase22 lrcase33 glss eu155 g77 eumemm [pweight = weight], backward bic ///
fix(reprecision repubbias endogg prednegg predposs)
// This estimates the "final best equation"
regress retstat reprecision repubbias endogg prednegg predposs pubyearr gdpp differencedd popgrowthh inflationn incomee ///
sehacc lrcase33 [pweight = weight], noc vce(cluster idstudy)
lincom -prednegg + predposs

log close
